<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE html>
<html>
<head>
<title></title>

<meta name="viewport" content="width=device-width, initial-scale=1.0"
	charset="utf-8">
<!-- 引入bootstrap -->
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<!-- 引入JQuery  bootstrap.js-->
<script src="${pageContext.request.contextPath}/js/jquery-3.2.1.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/caseoperation.js"></script>
<script src="${pageContext.request.contextPath}/js/cases.js"></script>

</head>
<body>
	<!-- 顶栏 -->
	<jsp:include page="../admin/top.jsp"></jsp:include>
	<!-- 中间主体 -->
	<div class="container" id="content">
		<div class="row">
			<%@ include file="/WEB-INF/jsp/admin/menu.jsp"%>
			<div class="col-md-10">
				<div class="panel panel-default">
					<div class="panel-heading">
						<div class="row">
							<h1 style="text-align: center;">添加用例</h1>
						</div>
					</div>
					<div class="panel-body">
						<form class="form-horizontal" role="form"
							action="${pageContext.request.contextPath}/cases/addCase"
							id="editfrom" method="post">
							<input type="hidden" name="id" id="id" value="${casesTest.id}">

							<div class="form-group">
								<td><label for="inputEmail3" class="col-sm-2 control-label">用例名称：</label></td>
								<td><input id="caseName" name="caseName" type="text"
									value="${casesTest.caseName}" style="width: 230px;"
									class="form-control" placeholder="请输入用例名称" /></td>
							</div>

							<div class="form-group">
								<label for="inputPassword3" class="col-sm-2 control-label"
									name="itemId">接口：</label>
								<div class="col-sm-10">
									<td><select class="form-control" name="portId" id="portId"
										style="width: 55%">
											<option value="0">请选择</option>
											<c:forEach var="casePortsList" items="${casePortsList}">
												<option value="${casePortsList.id}"
													<c:if test="${casePortsList.portName==casesTest.itemName}">selected</c:if>>
													${casePortsList.portName}</option>
											</c:forEach>
									</select></td>
									<td><input type="button" class="btn btn-primary"
										value="运行" onclick="runcase()"></td>
								</div>
							</div>


							<div class="form-group">
								<td><label for="inputPassword3"
									class="col-sm-2 control-label">返回结果：</label></td>
								<td><textarea style="overflow-x" rows="15" cols="100"
										id="result" name="result"></textarea></td>
							</div>

							<div class="form-group">
								<label class="col-sm-2 control-label">验证参数：</label>
								<div class="col-sm-8">
									<button id="add_request_body" class="btn btn-primary"
										type="button">
										<i class="fa fa-plus-square-o"></i>&nbsp;添加行
									</button>
								</div>
								<div class="col-sm-offset-2 col-sm-8">
									<table id="request_body" class="table col-sm-10">
										<thead>
											<tr>
												<th>参数名</th>
												<th>期望值</th>
												<th></th>
											</tr>
											<c:forEach var="listVar" items="${listVar}">
												<tr>
													<td name='varkey' contenteditable='true'>
														${listVar.varkey}</td>
													<td name='varvalue' contenteditable='true'>
														${listVar.varvalue}</td>
													<td>
														<button class='btn btn-danger' onclick='del_step(this)'>删除</button>
													</td>
												</tr>
											</c:forEach>
										</thead>
										<tbody>
										</tbody>
									</table>
								</div>
							</div>


							<div class="form-group">
								<td><label for="inputPassword3"
									class="col-sm-2 control-label">用例描述：</label></td>
								<td><textarea rows="3" cols="40" id="remark" name="remark">${casesTest.remark}</textarea>
								</td>
							</div>


							<div class="form-group">
								<td><label for="inputPassword3"
									class="col-sm-2 control-label">启用状态：</label></td>

								<td><c:choose>
										<c:when test="${'1' eq casesTest.status}">
											<label class="checkbox-inline"> <input type="radio"
												name="status" value="1" checked>启用
											</label>
											<label class="checkbox-inline"> <input type="radio"
												name="status" value="0">不启用 </td> </label>

								</c:when>
								<c:when test="${'0' eq casesTest.status}">
									<label class="checkbox-inline"> <input type="radio"
										name="status" value="1">启用
									</label>
									<label class="checkbox-inline"> <input type="radio"
										name="status" value="0" checked>不启用
										</td>
									</label>
								</c:when>
								</c:choose>
								</td>

							</div>
							</br> </br>

							<div class="form-group" style="text-align: center">
								<input type="button" class="btn btn-primary" value="提交"
									onclick="copycase()">
								<button class="btn btn-default" type="reset">重置</button>
							</div>
						</form>
					</div>

				</div>

			</div>
		</div>
	</div>
	<div class="container" id="footer">
		<div class="row">
			<div class="col-md-12"></div>
		</div>
	</div>
</body>
<script type="text/javascript">
	$("#nav li:nth-child(3)").addClass("active")
</script>
</html>